home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 06 General Architectures / 02 McLean / Listing2.cpp < prev    next >
Encoding:
Text File  |  2001-12-09  |  1.2 KB  |  50 lines

  1. /* Copyright (C) Alex McLean, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) Alex McLean, 2001"
  9.  */
  10.  
  11. // Now that we have our tasks split into two sets, we are 
  12. // able to look at a newer version of our main AI loop. 
  13.  
  14. CGame::UpdateAI( void )
  15. {
  16.     CCharacter   *pChar;
  17.     BOOL         bExit = FALSE;
  18.     unsigned int CharsProcessed=0;
  19.  
  20.     pChar =GetFirstCharacter();
  21.  
  22.     /* CONSTANT */
  23.     while( pChar )
  24.     {
  25.         pChar->ProcessConstantAI();
  26.         pChar = pChar->GetNext();
  27.     }
  28.  
  29.     /* PERIODIC */
  30.     while( CharsProcessed < m_CharsPerFrame )
  31.     {
  32.         m_pPresentCharacter->ProcessPeriodicAI();
  33.         CharsProcessed++;
  34.         m_pPresentCharacter = m_pPresentCharacter->GetNextCyclic();
  35.     }
  36. }
  37.  
  38. CCharacter::ProcessConstantAI( void )
  39. {
  40.     TrackTarget();
  41.     UpdateMovement();
  42. }
  43.  
  44. CCharacter::ProcessPeriodicAI( void )
  45. {
  46.     ProcessVision();
  47.     ProcessHearing();
  48. }
  49.  
  50.